﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExplodingCow.Basilisk.Logic
{
    /// <summary>
    /// Data type for getting an estimate of the items in the list
    /// </summary>
    public class ItemListEstimator
    {
        /// <summary>
        /// private singleton of class
        /// </summary>
        private static ItemListEstimator instance;
        /// <summary>
        /// private constructor for singleton-ness
        /// </summary>
        private ItemListEstimator()
        { 
        
        }
        /// <summary>
        /// Get the instance of singleton ItemListEstimator
        /// </summary>
        /// <returns>the only instance of ItemListEstimator</returns>
        public static ItemListEstimator GetItemListEstimator()
        {
            if (instance == null)
            {
                instance = new ItemListEstimator();
            }
            return instance;
        }
        /// <summary>
        /// Method for esitimating the items in the current list
        /// </summary>
        /// <param name="itemListItems">the list of items to be estimated</param>
        /// <returns>A Decimal value of the estimate cost of the items based on their individual quantity and cost</returns>
        public Decimal EstimateListItems(List<Item> itemListItems)
        {
            int tempItemQuantity = 0;
            Decimal tempItemCost = 0.00m;
            Decimal totalEstimatedCost = 0.00m;
            //estimate the cost of the items in the list
            for (int i = 0; i < itemListItems.Count; i++)
            {
                tempItemQuantity = itemListItems[i].Quantity;
                tempItemCost = itemListItems[i].Cost;

                totalEstimatedCost += tempItemQuantity * tempItemCost;

            }
            return totalEstimatedCost;
        }
    }
}
